<template>
	<view>
		<view class="address" v-for="item in adresList">
			<address-item :delivery_item="item"></address-item>
		</view>
		<view @click="to_add" class="footer">
			<text>新增收货地址</text>
		</view>
	</view>
</template>

<script>
	import userApi from '../../api/user.js'
	export default {
		data() {
			return {
				_id: '',
				adresList: []
			}
		},
		mounted() {
			// 获取仓库用户id
			this._id = this.$store.getters['user/get_id'];
			userApi.find_by_id({
				_id: this._id,
				cb: (data) => {
					console.log(data)
					this.$store.commit('user/set_delivery', data[0].delivery);
					this.adresList = data[0].delivery;
					console.log(this.adresList)
				}
			})
		},
		methods: {
			to_add() {
				uni.navigateTo({
					url:'/pages/address/add/add'
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	page {
		background-color: #d3d3d3;
	}

	.footer {
		position: absolute;
		bottom: 0;
		width: 100%;
		text-align: center;
		background-color: #78cdd1;
		height: 80rpx;
		line-height: 60rpx;
		padding-bottom: 20rpx;

		text {
			font-size: 40rpx;
			color: #FFFFFF;
			font-weight: bold;
		}
	}
</style>
